package com.wenc.psi.fgmt;

import android.os.Bundle;

import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.wenc.psi.R;
import com.wenc.psi.databinding.FragmentPersonBinding;
import com.wenc.psi.vmd.PersonViewModel;


public class PersonFragment extends Fragment {
    private PersonViewModel personViewModel;
    private FragmentPersonBinding binding;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 获取ViewModel
        personViewModel = new ViewModelProvider(getActivity()).get(PersonViewModel.class);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // 获取DataBinding
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_person, container, false);
        binding.setData(personViewModel);
        binding.setLifecycleOwner(this);

        return binding.getRoot();
        // Inflate the layout for this fragment
//        return inflater.inflate(R.layout.fragment_person, container, false);
    }
}